<?php

/**
 * Player form.
 *
 * @package    vogue
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class PlayerForm extends BasePlayerForm
{
  public function configure()
  {
  		unset($this['nba_debut'],$this['years_bro']);
  		
		  # WIDGETS
      $this->widgetSchema['fullname'] 	= new sfWidgetFormInputText(array(), array()); // TODO: should be autocomplete
      $this->widgetSchema['pic']    		= new sfWidgetFormInputFile(array(), array());
      $choices = GlobalLib::getArray('player_number');
      $this->widgetSchema['number']     = new sfWidgetFormChoice(array('choices'=>$choices), array('class'=>'w60px'));
      $this->widgetSchema['team_id']    = new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Team'), 'add_empty' => false));
    	$this->widgetSchema['biography']  = new sfWidgetFormTextarea(array(), array());
    	$choices = GlobalLib::getArray('gender');
      $this->widgetSchema['gender']     = new sfWidgetFormChoice(array('choices'=>$choices), array('class'=>'w60px'));
    	$this->widgetSchema['height']     = new sfWidgetFormInputText(array(), array('class'=>'w50px'));
    	$this->widgetSchema['weight']     = new sfWidgetFormInputText(array(), array('class'=>'w50px'));
    	$years = range(date('Y')-60, date('Y')-10);
    	$this->widgetSchema['born']       = new sfWidgetFormDate(array('format'=>'%year%-%month%-%day%', 'years'=>array_combine($years, $years)), array('class'=>'w60px'));
    	$this->widgetSchema['country_id'] = new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Country'), 'add_empty' => false));
    	$this->widgetSchema['state_id']   = new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('CountryState'), 'add_empty' => false));
    	$choices = GlobalLib::getArray('player_draft');
    	$this->widgetSchema['draft']      = new sfWidgetFormChoice(array('choices'=>$choices), array());
    	  	
    	# DEFAULTS
      $this->setDefault('country_id', 147);
      $this->setDefault('state_id', 73);
      
    	# VALIDATORS
    	$this->validatorSchema['fullname']   = new sfValidatorString();
    	$this->validatorSchema['pic'] 			 = new sfValidatorFile($this->getFileAttrs('player'), $this->getFileOpts());
    	$this->validatorSchema['number']     = new sfValidatorInteger(array(), array());
    	$this->validatorSchema['team_id']    = new sfValidatorPass();
    	$this->validatorSchema['biography']  = new sfValidatorPass();
    	$this->validatorSchema['gender']		 = new sfValidatorString(array(), array());
    	$this->validatorSchema['height']		 = new sfValidatorInteger(array(), array());
    	$this->validatorSchema['weight']  	 = new sfValidatorInteger(array(), array());
    	$this->validatorSchema['born']  		 = new sfValidatorPass();
    	$this->validatorSchema['country_id'] = new sfValidatorPass();
    	$this->validatorSchema['state_id']   = new sfValidatorPass();
    	$this->validatorSchema['draft']  		 = new sfValidatorPass();
    	
    	#HELP
    	$this->widgetSchema->setHelp('height', 'cm');
    	$this->widgetSchema->setHelp('weight', 'kg');
    	$this->widgetSchema->setHelp('logo', $this->getFileHelp());
  }

}